package com.accesshollywood.p2p;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import peerbase.PeerInfo;
import peerbase.util.SimplePingStabilizer;

import com.accesshollywood.grfxOrdering.basics.Users;
import com.accesshollywood.trace.Trace;

public class P2P {
	public static int		maxpeers	= 32;
	public static PeerInfo	mypd;
	public static P2Pnode	peer;

	public P2P() {
		mypd = new PeerInfo(Users.currentUser.getFullName(), Users.currentUser.getIP_local(), 8080);
		peer = new P2Pnode(maxpeers, mypd);
		peer.buildPeers(2);

		new javax.swing.Timer(3000, new RefreshListener()).start();

		(new Thread() { public void run() { peer.mainLoop(); }}).start();
		peer.startStabilizer(new SimplePingStabilizer(peer), 3000);
	}

	public static void refreshPeers(){
		peer.refreshPeers();
	}

	public static void refreshPeers(int[] orderNumbers){
		peer.refreshPeers( orderNumbers);
	}

	public static void refreshPeers(String fieldName, int[] orderNumbers){
		peer.refreshPeers(fieldName, orderNumbers);
	}
	
	class RefreshListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			// updateFileList();
			// updatePeerList();
		}
	}
}
